package book;
//书架
public class BookList {
    public static final int DEFAULT_SIZE = 10;//默认大小
    private Book[] book=new Book[DEFAULT_SIZE];
    private int usedSize;//记录当前数组当中有多少本书?
    public BookList(){
        book[0]=new Book("三国演义","罗贯中","小说",809);
        book[1]=new Book("西游记","吴承恩","小说",790);
        book[2]=new Book("红楼梦","曹雪芹","小说",792);
        book[3]=new Book("三国演义","盗版侠","修仙",10000);
        this.usedSize = 4;
    }
    public Book getBook(int pos) {

        return this.book[pos];
    }

    public void setBook(int pos,Book book) {
        //pos=getUsedSize();//默认放置在数组最后一个元素之后
        for (int i = usedSize; i >pos ; i--) {
            this.book[i]=this.book[i-1];
        }
        this.book[pos]=book;
    }
    public void setBook(Book book,int pos){
        this.book[pos]=book;
    }

    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }
}
